#ifndef __COLOR_H__
#define __COLOR_H__

#include "Math.h"

template <class Real>
class Color
{
public:
	// construction ( components in range [0,1] )
	Color();
	Color( Real r, Real g, Real b );
	Color( const Color<Real>& color );

	// access
	Real r,g,b;
	Real& operator[] ( int i ) const;
	operator Real* ();

	void clamp();
	void scale_by_max();

	Color<Real>& operator= ( const Color<Real>& color );
	bool operator== ( const Color<Real>& color ) const;
	bool operator!= ( const Color<Real>& color ) const;

	Color<Real> operator+ ( const Color<Real>& color ) const;
	Color<Real> operator- ( const Color<Real>& color ) const;
	Color<Real> operator* ( const Color<Real>& color ) const;
	Color<Real> operator/ ( const Color<Real>& color ) const;
	Color<Real> operator- () const;
	friend Color<Real> operator* ( Real scalar, const Color<Real>& color );
	Color<Real>& operator+= ( const Color<Real>& color );
	Color<Real>& operator-= ( const Color<Real>& color );
	Color<Real>& operator*= ( const Color<Real>& color );
	Color<Real>& operator/= ( const Color<Real>& color );

	static const Color<Real> BLACK;
	static const Color<Real> WHITE;
};

#endif